package com.ssl.controller;

import com.ssl.common.response.CommonResponse;
import com.ssl.service.UserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 用户信息
 */
@RestController
@RequestMapping("/user/info")
public class UserInfoController {
    @Autowired
    private UserInfoService userInfoService;

    /**
     * 检查手机绑定状态
     * @param personId
     * @return
     */
    @RequestMapping("/check-phone-bind-status")
    public CommonResponse checkPhoneBindStatus(@RequestHeader String personId) {
        return userInfoService.checkPhoneBindStatus(personId);
    }

    /**
     * 绑定手机号
     * @param personId
     * @param phoneNumber
     * @param code
     * @return
     */
    //绑定手机号
    @RequestMapping("/bind-phone-number")
    public CommonResponse bindPhoneNumber(@RequestHeader String personId, @RequestParam String phoneNumber, @RequestParam String code) {
        return userInfoService.bindPhoneNumber(personId, phoneNumber, code);
    }

    /**
     * 通过token获取用户信息
     * @param token
     * @return
     */
    @RequestMapping("/get-by-token")
    public CommonResponse getUserInfoByToken(@RequestParam String token) {
        return userInfoService.getUserInfoByToken(token);
    }
}
